/**
 * OWASP GoatDroid Project
 * 
 * This file is part of the Open Web Application Security Project (OWASP)
 * GoatDroid project. For details, please see
 * https://www.owasp.org/index.php/Projects/OWASP_GoatDroid_Project
 *
 * Copyright (c) 2011 - The OWASP Foundation
 * 
 * GoatDroid is published by OWASP under the GPLv3 license. You should read and accept the
 * LICENSE before you use, modify, and/or redistribute this software.
 * 
 * @author Jack Mannino, nVisium Security (https://www.nvisiumsecurity.com)
 * @created 2011
 */
package org.owasp.goatdroid.fourgoats.webservice.resources;

import javax.ws.rs.CookieParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.owasp.goatdroid.fourgoats.webservice.Constants;
import org.owasp.goatdroid.fourgoats.webservice.friends.FriendsImpl;
import org.owasp.goatdroid.fourgoats.webservice.friends.beans.FriendListBean;
import org.owasp.goatdroid.fourgoats.webservice.friends.beans.FriendProfileBean;
import org.owasp.goatdroid.fourgoats.webservice.friends.beans.FriendsBean;
import org.owasp.goatdroid.fourgoats.webservice.friends.beans.PendingFriendRequestsBean;
import org.owasp.goatdroid.fourgoats.webservice.friends.beans.PublicUsersBean;

@Path("/fourgoats/api/v1/friends")
public class Friends {

	@Path("list_friends")
	@GET
	@Produces("application/json")
	public FriendListBean getFriends(
			@CookieParam(Constants.SESSION_TOKEN_NAME) String sessionToken) {

		return FriendsImpl.getFriends(sessionToken);
	}

	@Path("request_friend")
	@GET
	@Produces("application/json")
	public FriendsBean requestFriend(
			@CookieParam(Constants.SESSION_TOKEN_NAME) String sessionToken,
			@QueryParam("userName") String userName) {

		return FriendsImpl.requestFriend(sessionToken, userName);

	}

	@Path("accept_friend_request")
	@GET
	@Produces("application/json")
	public FriendsBean acceptFriendRequest(
			@CookieParam(Constants.SESSION_TOKEN_NAME) String sessionToken,
			@QueryParam("userName") String userName) {

		return FriendsImpl.acceptOrDenyFriendRequest("accept", sessionToken,
				userName);

	}

	@Path("deny_friend_request")
	@GET
	@Produces("application/json")
	public FriendsBean denyFriendRequest(
			@CookieParam(Constants.SESSION_TOKEN_NAME) String sessionToken,
			@QueryParam("userName") String userName) {

		return FriendsImpl.acceptOrDenyFriendRequest("deny", sessionToken,
				userName);

	}

	@Path("remove_friend")
	@GET
	@Produces("application/json")
	public FriendsBean removeFriend(
			@CookieParam(Constants.SESSION_TOKEN_NAME) String sessionToken,
			@QueryParam("userName") String userName) {

		return FriendsImpl.removeFriend(sessionToken, userName);
	}

	@Path("get_pending_requests")
	@GET
	@Produces("application/json")
	public PendingFriendRequestsBean getPendingFriendRequests(
			@CookieParam(Constants.SESSION_TOKEN_NAME) String sessionToken) {

		return FriendsImpl.getPendingFriendRequests(sessionToken);
	}

	@Path("search_users")
	@GET
	@Produces("application/json")
	public PublicUsersBean getPublicUsers(
			@CookieParam(Constants.SESSION_TOKEN_NAME) String sessionToken) {

		return FriendsImpl.getPublicUsers(sessionToken);
	}

	@Path("view_profile")
	@GET
	@Produces("application/json")
	public FriendProfileBean getProfile(
			@CookieParam(Constants.SESSION_TOKEN_NAME) String sessionToken,
			@QueryParam("userName") String userName) {

		return FriendsImpl.getProfile(sessionToken, userName);
	}

}
